import json
import os
_filepath = os.path.join(os.path.dirname(__file__), 'config.json')

def read_json(filepath=_filepath):
    with open(filepath, 'r', encoding='utf-8') as f:
        data = json.load(f)
    return data

def write_json(data,filepath=_filepath):
    with open(filepath, 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=4)

def set_config(key, value):
    data = read_json()
    data[key] = value
    write_json(data)